package com.thy.controller;


import com.hospital.common.base.PageResult;
import com.hospital.common.base.Result;
import com.hospital.common.pojo.TDepartment;
import com.hospital.common.vo.management.module.DepartmentAndStatVo;
import com.hospital.common.vo.management.module.DepartmentVo;
import com.hospital.common.vo.management.module.DoctorInfoVo;
import com.thy.service.TDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 科室表 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-09-11
 */
@RestController
@RequestMapping("/department")
public class TDepartmentController {
    @Autowired
    private TDepartmentService departmentService;

    /**
     * 获取所有科室信息
     * @author iT唐
     * @return List<DepartmentVo>
     */
    @GetMapping("/getAllDepartment")
    public Result<List<DepartmentVo>> getAllDepartment() {
        List<DepartmentVo> departmentVos = departmentService.getAllDepartment();
        return Result.success(departmentVos);
    }

    /**
     * 根据科室id获取医生信息
     *  <br>用户端查看科室医生信息
     * @param departmentId
     * @author iT唐
     * @return List<DepartmentVo>
     */
    @GetMapping("/getDoctor/byDepartmentId")
    public Result<List<DoctorInfoVo>> getDoctorByDepartmentId(@RequestParam("departmentId") Long departmentId) {
        List<DoctorInfoVo> doctorInfoVos = departmentService.getDoctorByDepartmentId(departmentId);
        return Result.success(doctorInfoVos);
    }

    /**
     * 添加科室
     * @author iT唐
     * @param department
     * @return  String
     */
    @PostMapping("/addDepartment")
    public Result<String> addDepartment(@RequestBody TDepartment department) {
        departmentService.addDepartment(department);
        return Result.success("添加成功");
    }

    /**
     * 根据科室id批量获取医生信息
     *  <br>管理端查看科室医生信息
     * @param departmentIds
     * @return PageResult<DoctorInfoVo>
     */
    @GetMapping("/getDoctor/byDepartmentIds")
    public Result<PageResult<DoctorInfoVo>> getDoctorByDepartmentIds(@RequestParam("departmentIds") List<Long> departmentIds,@RequestParam("pageNum")Integer pageNum,@RequestParam("pageSize")Integer pageSize) {
        PageResult<DoctorInfoVo> doctorInfoVos = departmentService.getDoctorByDepartmentIds(departmentIds,pageNum,pageSize);
        return Result.success(doctorInfoVos);
    }

    /**
     * 获取所有科室以及对应医生统计信息
     */
    @GetMapping("/getDepartmentAndStat")
    public Result<List<DepartmentAndStatVo>> getDepartmentAndStat() {
        return Result.success(departmentService.getDepartmentAndStat());
    }
}
